package 抽象类.练习;

abstract class Animal{
    String name ;
    Animal(String name){
        this.name =name;
    }

    abstract void bark();
}
class Dog extends Animal{
    Dog(String name) {
        super(name);
    }

    @Override
    void bark() {
        System.out.println(name+"汪汪叫");
    }
}
class Cat extends Animal{
    Cat(String name) {
        super(name);
    }

    @Override
    void bark() {
        System.out.println(name +"喵喵叫");
    }
}
public class Abstract_1 {
    static void fun1(Animal animal){
        animal.bark();
    }
    public static void main(String[] args) {
        Dog dog = new Dog("大黄");
        Cat cat = new Cat("大黑");
        fun1(dog);
        fun1(cat);
    }
}
